@extends('layout.wechat_frame')

@section('main')

    <header class="mui-bar mui-bar-nav">
        <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
        <h1 class="mui-title">询价报价-报价单报价</h1>
    </header>
    <div class="mui-content">
        <form method="post" action="{{ route('enquiryQuote.reply', ['enquiry' => $enquiry->id])}}">
            {!! csrf_field() !!}
        <ul class="mui-table-view mui-table-view-striped mui-table-view-condensed">
            <li class="mui-table-view-cell">
                <h5 ><span>结束倒计时：</span><span class="ips-text-red"><span class="colockbox" id="colockbox-global"><span class="hour">00</span>:<span class="minute">00</span>:<span class="second">00</span></span></span></h5>
                <h5 class="mui-ellipsis ips-text-blue">提交报价前请确认能满足各项信息要求！</h5>
                <h4 style="margin: 10px 0px;">{{ $enquiry->title }}</h4>
                <h5 >质量指标:</h5>
			<textarea class="ips-textarea" rows="5" placeholder="" readonly>{{ $enquiry->quality }}</textarea>
                <h5 >质量修改意见</h5>
                <textarea name="quality"  class="ips-textarea" rows="3" placeholder="" >{{ old('quality') }}</textarea>
                @if ($errors->has('quality'))
                    <p style="color:red">{{ $errors->first('quality') }}</p>
                @endif
                <h5 ><span class="ips-span-first">数量</span><span class="ips-text-blue">{{ strval((float)$enquiry->quantity) }}吨</span></h5>
                <h5 ><span class="ips-span-first">船期</span><span>{{ $enquiry->sailing_date }}</span></h5>
                <h5 >交货地点及方式</h5>
                <textarea class="ips-textarea" rows="2" placeholder="" readonly>{{ $enquiry->terms_of_delivery }}</textarea>
                <h5 ><span class="ips-span-first">付款方式</span><span class="ips-span-input">
			<input type="text" name="payment" class="ips-inputtext" placeholder="" value="{{ old('payment') }}" /></span></h5>
                @if ($errors->has('payment'))
                    <p style="color:red">{{ $errors->first('payment') }}</p>
                @endif
                <h5 ><span class="ips-span-first">价格（人民币）</span><span class="ips-span-input">
			<input type="text" name="price" class="ips-inputtext" placeholder="" value="{{ old('price') }}" /></span><span>元/吨</span></h5>
                @if ($errors->has('price'))
                    <p style="color:red">{{ $errors->first('price') }}</p>
                @endif
                <h5 ><span class="ips-span-first">报价有效期</span><span class="ips-span-input">
			<input type="text" name="price_validity" class="ips-inputtext" value="{{ old('price_validity') }}" /></span><span>小时（报价截止后）</span></h5>
                @if ($errors->has('price_validity'))
                    <p style="color:red">{{ $errors->first('price_validity') }}</p>
                @endif
                <h5 ><span class="ips-span-first">补充说明</span><span></span></h5>
                <textarea name="remark" class="ips-textarea" rows="2" placeholder="若没有请留空" >{{ old('remark') }}</textarea>
                @if ($errors->has('remark'))
                    <p style="color:red">{{ $errors->first('remark') }}</p>
                @endif
            </li>
        </ul>
        <div class="mui-content-padded ips-detail-page-bottom">
            <div class="mui-button-row">
                <button type="submit" id="saveIQuote" class="mui-btn mui-btn-primary" >提交报价</button>&nbsp;&nbsp;
            </div>
        </div>
        </form>
    </div>
@section('js')

    <script type="text/javascript">

        // 倒计时
        function countDown(end,start,id){
            //var day_elem = $(id).find('.day');
            var hour_elem = $(id).find('.hour');
            var minute_elem = $(id).find('.minute');
            var second_elem = $(id).find('.second');
            var end_time = new Date(end).getTime(),//月份是实际月份-1
                    sys_second = (end_time-new Date(start).getTime())/1000;
            var timer = setInterval(function(){
                if (sys_second > 1) {
                    sys_second -= 1;
                    //var day = Math.floor((sys_second / 3600) / 24);
                    var hour = Math.floor((sys_second / 3600) % 24);
                    var minute = Math.floor((sys_second / 60) % 60);
                    var second = Math.floor(sys_second % 60);
                    //day_elem && $(day_elem).text(day);//计算天
                    $(hour_elem).text(hour<10?"0"+hour:hour);//计算小时
                    $(minute_elem).text(minute<10?"0"+minute:minute);//计算分钟
                    $(second_elem).text(second<10?"0"+second:second);//计算秒杀
                } else {
                    clearInterval(timer);
                }
            }, 1000);
        }

        $(document).ready(function() {

            $.get('{{ route('system.datetime') }}', function (datetime) {
                countDown('{{ str_replace('-', '/', $enquiry->stop_at) }}', datetime.replace(/-/g, '/'), '#colockbox-global');
            });
        });

    </script>

@stop